package com.cl.short_video_java.service.impl;

/**
 * @Author 付
 * @Date 2024-03-28 16:48
 * @Version 1.0
 * @description
 * @since 1.0
 */

import cn.hutool.core.math.MathUtil;
import cn.hutool.core.util.RandomUtil;
import com.cl.short_video_java.dto.MailDto;
import com.cl.short_video_java.util.MailUtils;
import com.cl.short_video_java.util.RedisUtil;
import com.cl.short_video_java.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import javax.mail.internet.MimeMessage;

@Service
public class MailService {


	@Resource
	RedisUtil redisUtil;
	@Autowired
	MailUtils mailUtils;


	public void ostSeander(String mail) throws Exception {
		long l = RandomUtil.randomLong(6);
		String s = redisUtil.get("mail" + mail);
		Assert.isTrue(StringUtils.isEmpty(s), "抱歉，不可重复发送验证码");
		mailUtils.sendTemplateMail(mail, "短视频平台-邮箱验证码通知", "Email_Template.html");
	}
}
